
<?php

$file_handle = fopen("conf.txt", "r");
$line = split(":",fgets($file_handle));

$hostname= $line[0];
$db_user= $line[1];
$db_pass= $line[2];
$db_name= chop($line[3]);

fclose($file_handle);

session_start();

$con = mysql_connect($hostname,$db_user,$db_pass);

if (!$con)
{
    die('Could not connect: ' . mysql_error());
}
//date_default_timezone_set('UTC');

mysql_select_db($db_name, $con);

$username = $_GET['username'];
$password = $_GET['password'];

$sql='SELECT * FROM usuarios WHERE username="'.$username.'" and
password="'.$password.'";';

$result=mysql_query($sql,$con);

$count=mysql_num_rows($result);
//echo $count;

if($count==1){
    $_SESSION["username"] = $username;
    //session_register("username");
    echo 1;
}
else{
    echo 0;
}

mysql_close($con);

 
?>
